<template>
	<view>
		
		<view class="cu-card case " v-for="video in videoList" :key="video.id" @tap="gotoVideoInfo(video.id)">
			<view class="cu-item " >
				<view class="image"  style="background-color: #000000;">
					<image :src=webUrl+video.cover_path mode="aspectFit"></image>
					<view class="cu-bar bg-shadeBottom"> <text class="text-cut">{{video.audio_desc}}</text></view>
				</view>
				<view class="cu-list" style="margin-bottom: 15upx;">
					<view class="cu-item">
						<view class="cu-avatar lg round margin-left" style="margin-top: -30upx; " :style="{backgroundImage:'url('+webUrl + video.u_face_image_path + ')'}"></view>
						<view class="flex justify-end text-gray text-sm" style="margin-top: -30upx;">
							<text class="cuIcon-attentionfill margin-lr-xs"></text> 10
							<text class="cuIcon-appreciatefill margin-lr-xs"></text> 20
							<text class="cuIcon-messagefill margin-lr-xs"></text> 30	
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	}from 'vuex' 
	export default {
		computed: mapState(['hasLogin','webUrl']),
		onLoad() {
			var page = this.curPage
			this.queryVideoList(page)
		},
		onReachBottom() {
			console.log("totalPage="+this.totalPage)
			if(this.curPage <= this.totalPage){
				this.curPage = this.curPage + 1
				this.queryVideoList(this.curPage)
			}else{
				uni.showToast({
					icon:"none",
					title:"没有视频啦"
				})
			}
			console.log("curPage="+this.curPage)
		},
		onPullDownRefresh() {
			this.curPage = 1
			this.queryVideoList(this.curPage)
		},
		data() {
			return {
				totalPage:1,
				curPage:1,
				videoList:[]
			};
		},
		methods:{
			test(){
				uni.navigateTo({
					url:"../upload/upload"
				})
			},
			queryVideoList(page){
				uni.request({
					url:this.webUrl+'showVideo?pageNum='+page,
					success: (res) => {
						uni.stopPullDownRefresh()
						uni.hideLoading()
						var pageInfoObj = res.data.data
						if(this.curPage == 1){
							this.videoList = []
						}
						var newViodeList = pageInfoObj.list
						//将新的视频信息添加进数组中去
						this.videoList = this.videoList.concat(newViodeList)
						this.curPage = pageInfoObj.pageNum
						this.totalPage = pageInfoObj.pages
					},
					fail() {
						uni.showToast({
							title:'请求失败',
							icon:'none'
						})
						uni.hideLoading()
					}
				})
			},
			gotoVideoInfo(video_id){
				uni.navigateTo({
					url:"../videoIndex/videoIndex?video_id="+video_id
				})
			}
		}
	}
</script>

<style >
	
	
</style>
